package middle;

public class Solution_713 {

    public int numSubarrayProductLessThanK(int[] nums, int k) {
        int left = 0, right = 0, count = 0;
        long sum = nums[0];
        while (left < nums.length) {
            if (sum < k) {
                System.out.println(left + "--" + right);
                count = count + right - left + 1;
                right++;
                if (right == nums.length) {
                    break;
                }
                sum *= nums[right];
            } else {
                sum /= nums[left];
                left++;
            }
        }
        return count;
    }

    public static void main(String[] args) {
        Solution_713 model = new Solution_713();
        System.out.println(model.numSubarrayProductLessThanK(new int[]{10, 5, 2, 6}, 100));
        System.out.println(model.numSubarrayProductLessThanK(new int[]{1, 2, 3}, 0));
    }
}
